import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
// 引入Vant
import {
  Button,
  Icon,
  Tabbar,
  TabbarItem,
  Search,
  Card,
  Tag,
  Grid,
  GridItem,
  List,
  PullRefresh,
  Image as VanImage,
  Cell,
  CellGroup,
  Form,
  Field,
  Checkbox,
  NavBar,
  Popup,
  Calendar,
  Swipe,
  SwipeItem,
  Toast,
  Dialog,
  Badge,
  Switch,
  ActionSheet
} from 'vant'
// 引入样式
import 'vant/lib/index.css'
import './style.css'

const app = createApp(App)

// 创建 Pinia 实例
const pinia = createPinia()

// 注册Vant组件
const vantComponents = [
  Button,
  Icon,
  Tabbar,
  TabbarItem,
  Search,
  Card,
  Tag,
  Grid,
  GridItem,
  List,
  PullRefresh,
  VanImage,
  Cell,
  CellGroup,
  Form,
  Field,
  Checkbox,
  NavBar,
  Popup,
  Calendar,
  Swipe,
  SwipeItem,
  Badge,
  Switch,
  ActionSheet
]

vantComponents.forEach(component => {
  app.use(component)
})

// 注册全局属性
app.config.globalProperties.$toast = Toast
app.config.globalProperties.$dialog = Dialog

// 使用插件
app.use(pinia)
app.use(router)
// 挂载应用
app.mount('#app')
